package io.vov.vitamio.adapter;

import io.vov.vitamio.entity.TVProgram;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ListView;

import com.ndjh.onlinetv.R;
import com.yixia.zi.utils.Log;

public class TVProgramsGridViewDescAdapter extends BaseAdapter {

	private Context mContext;
	private LayoutInflater mInfInflater;
	private List<TVProgram> mProgramsList = new ArrayList<TVProgram>();
	private TVProgram currentProgram;
	private TVProgramsListViewDescAdapter TVProgramsListViewDescAdapter;
	public TVProgramsGridViewDescAdapter(Context contect, List programsList,TVProgram TvProgram) {
		mContext = contect;
		mInfInflater = LayoutInflater.from(contect);
		mProgramsList = programsList;
		currentProgram = TvProgram;
		Log.e("TVProgramsGridViewDescAdapter", "TVProgramsGridViewDescAdapter");
	}

	@Override
	public int getCount() {
		return mProgramsList!=null? /*mProgramsList.size()*/3:0;
	}

	@Override
	public Object getItem(int position) {

		return mProgramsList != null ? mProgramsList.get(position):null;
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		final ViewHolder holder;
		if (convertView == null) {
			convertView = mInfInflater.inflate(R.layout.tv_programs_list_desc, null);
			holder = new ViewHolder(convertView);
			convertView.setTag(holder);
		}else {
			holder = (ViewHolder) convertView.getTag();
		}
		TVProgramsListViewDescAdapter = new TVProgramsListViewDescAdapter(mContext, mProgramsList, position, currentProgram);
		holder.mTVProgramsDescListview.setAdapter(TVProgramsListViewDescAdapter);
		return convertView;
	}
	 private class ViewHolder{
			private ListView mTVProgramsDescListview;
			public ViewHolder(View view){
				this.mTVProgramsDescListview = (ListView) view.findViewById(R.id.tv_programs_desc_listview);
			}
		}

}
